class Solution {
public:
    vector<int> twoSum(vector<int>& p, int t) {
        int n=p.size();
        int left=0;
        vector<int> v;
        for(left=0;;++left)
        {
            int right=n-1;
            while(left<right)
            {
                if(t-p[left]>p[right])
                    break;
                else if(t-p[left]<p[right])
                {
                    right--;
                }
                else
                {
                    v.push_back(p[left]);
                    v.push_back(p[right]);
                    return v;
                }
            }
        }
    }
};
